﻿using System;
using System.Collections.Generic;
using System.Data.Objects;
using System.Transactions;
using System.Linq;


namespace NorthwindEntities
{
    class Program
    {
        static void Main(string[] args)
        {
            //CustomerManipulator.AddCustomer("AAAAA","Ebati qkoto productions",null,null,
                //null,null,null,null,null,null,null);
            //CustomerManipulator.ModifyCustomer("AAAAA","Montana");
            //CustomerManipulator.DeleteProduct("AAAAA");

            //HashSet<Customer> customers = GetAllCustomersByOrderDate.GetAllCustomers();

            //foreach (var customer in customers) 
            //{
            //    Console.WriteLine("{0} {1}",customer.CustomerID,customer.ContactName);
            //}

            //IEnumerable<IdAndContactName> customers = GetAllCustomersByOrderDate.GetAllCustomersQuerry();
            //foreach (var customer in customers) 
            //{
            //    Console.WriteLine("{0} {1}", customer.CustomerID, customer.ContactName);
            //}

            //IEnumerable<OrderAddressAndName> orders = 
            //    SelectSalesByRegionInPeriod.GetSalesByRegionInPeriond("RJ", "1997-01-01", "1998-01-01");
            //foreach (var order in orders) 
            //{
            //    Console.WriteLine("{0} {1} {2}",order.ShipName, order.ShipAddress, order.TotalSum);
            //}

            //NorthwindEntities context = new NorthwindEntities();
            //foreach (var employee in context.Employees) 
            //{
            //    EmployesWithTeritories pesho = new EmployesWithTeritories(employee.EmployeeID);
            //    Console.WriteLine("{0} {1}",pesho.FirstName,pesho.LastName);
            //    foreach (var item in pesho.Teritories) 
            //    {
            //        Console.WriteLine("\t{0}",item.TerritoryDescription);
            //    }
            //}

            using (TransactionScope scope = new TransactionScope()) 
            {
                try
                {
                    NorthwindEntities context = new NorthwindEntities();
                    //Order newOrder = new Order();
                    //newOrder.CustomerID = "BONAP";
                    //newOrder.ShipCountry = "France";
                    //context.Orders.AddObject(newOrder);

                    //int orderId = 0;
                    //foreach (var order in context.Orders) 
                    //{
                    //     orderId = order.OrderID;
                    //}
                    //Order_Detail newOrderDetail = new Order_Detail();

                    //newOrderDetail.OrderID = orderId;
                    //newOrderDetail.ProductID = 1;
                    //newOrderDetail.UnitPrice = 20M;
                    //newOrderDetail.Quantity = 10;
                    //newOrderDetail.Discount = 0.0F;
                    
                    //context.SaveChanges();
                    //scope.Complete();
                    //Console.WriteLine("Spokosichko e nared");
                    
                }
                catch (Exception ex) 
                {
                    Console.WriteLine("Neshto se preeba");
                }
            }
        }
    }
}
